package com.example.homeworkhelper.faq;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.homeworkhelper.R;

import java.util.ArrayList;
import java.util.List;

public class FaqDataAdapter extends RecyclerView.Adapter<FaqViewHolder> {
    private ArrayList<FaqData> faqDataArrayList;
    private FaqOnClickListener faqOnClickListener;
    private Context context;

    public FaqDataAdapter(ArrayList<FaqData> faqDataArrayList, FaqOnClickListener faqOnClickListener, Context context) {
        super();
        this.faqDataArrayList = faqDataArrayList;
        this.faqOnClickListener = faqOnClickListener;
        this.context = context;
    }

    @NonNull
    @Override
    public FaqViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new FaqViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.view_faq_card, parent, false));
    }

    @Override
    public void onBindViewHolder(@NonNull FaqViewHolder holder, int position) {
        holder.onBind(position, faqDataArrayList.get(position));
//        holder.setOnClickListener((view)->{
//            if (faqOnClickListener != null) {
//                faqOnClickListener.onItemClick(position, faqDataArrayList.get(position), context);
//            }
//        });
//        holder.setLongClickListener((view)->{
//            if ( faqOnClickListener != null) {
//                faqOnClickListener.onItemClick(position, faqDataArrayList.get(position), context);
//            }
//            return false;
//        });
    }


    @Override
    public int getItemCount() {
        return faqDataArrayList.size();
    }
}
